<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //   5.把给定样式的字符串转化成小驼峰命名
        //  例如    border - top - left - radius  => borderTopLeftRadius
        function lowerCamelCase(str) {
            let arr = str.split('-')
            let str1 = arr[0]
            for (let i = 1; i < arr.length; i++) {
                arr[i] = arr[i].replace(arr[i][0], arr[i][0].toLocaleUpperCase())
                str1 += arr[i]
            }

            return str1
        }

        let str = 'border-top-left-radius'

        console.log(lowerCamelCase(str));







        // 字符串转换为数组
        function StringBianArray(str, s) {
            let arr = []
            while (str.indexOf(s) !== -1) {
                let str1 = ''
                let str2 = ''
                for (let i = 0; i < str.length; i++) {
                    if (i < str.indexOf(s)) {
                        str1 += str[i]
                    } else if (i > str.indexOf(s)) {
                        str2 = str2 + str[i]
                    }
                }
                arr.push(str1)
                str = str2
            }
            arr.push(str)
            return arr
        }

        console.log(StringBianArray(str, '-'));

    </script>
</body>

</html>